<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<body>
	<ui:composition template="../templates/templatesemheader.xhtml">
	 	<ui:define name="content">
		    <div class="container">			  
					<div class="row">
						<div class="col-md-12">
							<div class="home test-center">
								<h1>Manter Perguntas</h1>
								<!-- a4j:status onstart="#{rich:component('statPane')}.show()" onstop="#{rich:component('statPane')}.hide()" /-->   
								<h:form id="perguntaRespForm" styleClass="form-horizontal" role="form" prependId="false">																
									<h:messages  style="text-align:center;" id="messages" styleClass="text-info bg-info :focus"/>
									<div id="pergunta" class="form-group" >
										<h:outputText value="Pergunta: " styleClass="col-sm-2 control-label"/>
										<div class="col-sm-10"> 
											<h:inputTextarea  label="Nome" required="true" requiredMessage="O campo Pergunta é um campo obrigatório!"  maxlength="1000" styleClass="form-control" value="#{perguntaRespostaController.pergunta.descricao}" />
										</div>
									</div>
									<div class="form-group">
										<h:outputText value="Marque a alternativa correta para pergunta:" styleClass="col-sm-4 control-label"/>
										<div class="col-sm-10"> 
											<h:selectOneRadio required="true" requiredMessage="O campo Alternativa Correta é um campo obrigatório!" style="margin-left:400px; margin-top:-20px; width:200px;"  layout="lineDirection" value="#{perguntaRespostaController.opcaoCorreta}" >
													<f:selectItem itemValue="0" itemLabel="A " />
													<f:selectItem itemValue="1" itemLabel="B "/>
													<f:selectItem itemValue="2" itemLabel="C "/>
													<f:selectItem itemValue="3" itemLabel="D "/>
											</h:selectOneRadio>
										</div>
									</div>
										<div class="form-group">
											<h:outputText value="A:" styleClass="col-sm-2 control-label"/>
											<div class="col-sm-10"> 
												<h:inputText required="true" requiredMessage="O campo Alternativa A é um campo obrigatório!" title="A" label="Reposta A" maxlength="490" autocomplete="off" value="#{perguntaRespostaController.pergunta.respostas[0].descricao}" styleClass="form-control"/>
											</div>
										</div>
										<div class="form-group">
											<h:outputText value="B:" styleClass="col-sm-2 control-label"/>
											<div class="col-sm-10"> 
												<h:inputText required="true" requiredMessage="O campo Alternativa B é um campo obrigatório!" title="B" label="Reposta B" maxlength="490" autocomplete="off" value="#{perguntaRespostaController.pergunta.respostas[1].descricao}" styleClass="form-control"/>
											</div>
										</div>
										<div class="form-group">
											<h:outputText value="C:" styleClass="col-sm-2 control-label"/>
											<div class="col-sm-10"> 
												<h:inputText required="true" requiredMessage="O campo Alternativa C é um campo obrigatório!" title="C" label="Reposta C" maxlength="490" autocomplete="off" value="#{perguntaRespostaController.pergunta.respostas[2].descricao}" styleClass="form-control"/>
											</div>
										</div>
										<div class="form-group">
											<h:outputText value="D:" styleClass="col-sm-2 control-label"/>
											<div class="col-sm-10"> 
												<h:inputText required="true" requiredMessage="O campo Alternativa D é um campo obrigatório!" title="D" label="Reposta D" maxlength="490" autocomplete="off" value="#{perguntaRespostaController.pergunta.respostas[3].descricao}" styleClass="form-control"/>
											</div>
										</div>
										<div class="form-group">
											<div class="col-sm-offset-2 col-sm-10"> 
												<h:commandLink action="salvar" style="margin-right:15px;" value="Salvar" styleClass="btn btn-primary" actionListener="#{perguntaRespostaController.salvar()}" />
												<h:commandLink immediate="true" action="buscar"  style="margin-left:15px;" value="Buscar" styleClass="btn btn-primary" actionListener="#{perguntaRespostaController.buscar()}" />
											</div>
										</div>
									<br/>
									<br/>
									<br/>
									<rich:dataTable id="tabelaPerguntas"  iterationStatusVar="it" value="#{perguntaRespostaController.perguntas}" var="pergunta" rendered="#{perguntaRespostaController.perguntas.size() > 0}" styleClass="table table-striped" headerClass="info" rows="5">										 
                						<f:facet name="header">
                								<h:outputText value="Perguntas " />
                						</f:facet>
                						<rich:column>
                								<f:facet name="header">ID</f:facet>
                								<h:outputText value="#{pergunta.id}"/>                								
                						<f:facet name="footer">ID</f:facet>
        								</rich:column>
                						<rich:column>
                								<f:facet name="header">Descrição</f:facet>
                								<h:outputText value="#{pergunta.descricao}"/>                								
                						<f:facet name="footer">Descrição</f:facet>
        								</rich:column>
                						<rich:column>
                								<f:facet name="header">Resposta Correta</f:facet>
                								<h:outputText value="#{pergunta.respostaCorreta.descricao}"/>                								
                						<f:facet name="footer">Resposta Correta</f:facet>
        								</rich:column>
                						<rich:column>
                							<f:facet name="header">Editar</f:facet>
                							 <a4j:commandLink render="perguntaRespForm" execute="@this">
							                    <h:graphicImage value="/resources/img/edit.gif" alt="edit" width="30px;" height="30px;" />							                    
							                    <f:setPropertyActionListener target="#{perguntaRespostaController.pergunta}" value="#{pergunta}" />
							                </a4j:commandLink>
        								</rich:column>
        								<f:facet name="footer">        				
                								 <rich:dataScroller render="tabelaPerguntas" for="tabelaPerguntas"  page="#{perguntaRespostaController.pagina}"/>                								
                						</f:facet>									
									</rich:dataTable>
									
										<rich:popupPanel id="statPane" autosized="true">
								            <h:graphicImage value="/resources/img/load.gif" alt="load" />
								            Aguarde...
								        </rich:popupPanel>	
								</h:form>
							</div>
						</div>
					</div>
				</div>
			</ui:define>
		</ui:composition>
	</body>
</html>